1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77#include <stdio.h>
78#include <stdlib.h>
79#include <string.h>
80
82#include "common/tools_common.h"
83#include "common/video_reader.h"
84
85static const char *exec_name;
86
87void usage_exit(void) {
88 fprintf(stderr, "Usage: %s <infile> <outfile>\n", exec_name);
89 exit(EXIT_FAILURE);
90}
91
92int main(int argc, char **argv) {
93 int frame_cnt = 0;
94 FILE *outfile = NULL;
95 AvxVideoReader *reader = NULL;
96 const AvxVideoInfo *info = NULL;
97
98 exec_name = argv[0];
99
100 if (argc != 3) die("Invalid number of arguments.");
101
102 reader = aom_video_reader_open(argv[1]);
103 if (!reader) die("Failed to open %s for reading.", argv[1]);
104
105 if (!(outfile = fopen(argv[2], "wb")))
106 die("Failed to open %s for writing.", argv[2]);
107
108 info = aom_video_reader_get_info(reader);
109
111 if (!decoder) die("Unknown input codec.");
112
114
117 die("Failed to initialize decoder.");
118
119 while (aom_video_reader_read_frame(reader)) {
122 size_t frame_size = 0;
123 const unsigned char *frame =
124 aom_video_reader_get_frame(reader, &frame_size);
126 die_codec(&codec, "Failed to decode frame.");
127
129 aom_img_write(img, outfile);
130 ++frame_cnt;
131 }
132 }
133
134 printf("Processed %d frames.\n", frame_cnt);
136
137 printf("Play: ffplay -f rawvideo -pix_fmt yuv420p -s %dx%d %s\n",
138 info->frame_width, info->frame_height, argv[2]);
139
140 aom_video_reader_close(reader);
141
142 fclose(outfile);
143
144 return EXIT_SUCCESS;
145}
Describes the decoder algorithm interface to applications.
struct aom_image aom_image_t
Image Descriptor.
const char * aom_codec_iface_name(aom_codec_iface_t *iface)
Return the name for a given interface.
struct aom_codec_ctx aom_codec_ctx_t
Codec context structure.
const struct aom_codec_iface aom_codec_iface_t
Codec interface structure.
Definition aom_codec.h:271
aom_codec_err_t aom_codec_destroy(aom_codec_ctx_t *ctx)
Destroy a codec instance.
const void * aom_codec_iter_t
Iterator.
Definition aom_codec.h:305
aom_image_t * aom_codec_get_frame(aom_codec_ctx_t *ctx, aom_codec_iter_t *iter)
Decoded frames iterator.
aom_codec_err_t aom_codec_decode(aom_codec_ctx_t *ctx, const uint8_t *data, size_t data_sz, void *user_priv)
Decode data.
#define aom_codec_dec_init(ctx, iface, cfg, flags)
Convenience macro for aom_codec_dec_init_ver()
Definition aom_decoder.h:129